#ifndef _UNIT_H_
#define _UNIT_H_

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <vector>
#include "SpriteManager.h"
#include "Map.h"
using namespace sf;

enum {
    DIR_S = 0,
    DIR_SW,
    DIR_W,
    DIR_NW,
    DIR_N,
    DIR_NE,
    DIR_E,
    DIR_SE
};
enum {
    ACT_MOVE = 0,
    ACT_ATTACK,
    ACT_ROTATE
};
class Map;
class SpriteManager;

class Unit {
    protected:
        Map &map;
        int x;
        int y;
        int dir;
        int player;
        int health;
        Sprite sprites[8];

    public:
        Unit(Map &map);
        virtual ~Unit();

        int GetTileX();
        int GetTileY();

        void SetDirection(int newDir);
        void RotateCW();
        void RotateCCW();

        virtual void Move(int newX, int newY);
        virtual void Attack(int x, int y);
        virtual void TakeDamage(int damage);
        virtual std::vector<Vector2i> GetActions(int actionType);
        virtual void DoAction(int actionType, int x, int y);

        virtual void Die();
        virtual void Update(float dt);
        virtual void Render(SpriteManager &spriteManager);
};

#endif
